package packets.s2cpackets;

import datatypes.MCItemSlot;
import entities.Player;
import exceptions.UnrecoverableException;
import packets.SPacket;

public class S0x14 extends SPacket {
	public S0x14(Player player) {
		super(0x14);
		
		addInt(player.geteid());				//EID
		addString(player.getName());			//Name
		addInt(player.getLastLocation().x);	//X as abs int
		addInt(player.getLastLocation().y);	//Y as abs int
		addInt(player.getLastLocation().z);	//Z as abs int
		add((byte) player.getYaw());			// Rotation
		add((byte) player.getPitch());		// Pitch
		
		short selecteditem = 0;
		try {
			MCItemSlot currentitem = player.getHeldItemAtSlot(player.getSelectedSlot());
			selecteditem = currentitem.getItem().getItemId();
		} catch (UnrecoverableException e) {
			e.printStackTrace();
		} catch (NullPointerException e) {}
		
		addShort(selecteditem);		// Current item
	}
}
